import request from '@/utils/request'

// 获取订单统计数据
export function getOrderStatistics() {
  return request({
    url: '/api/admin/order/statistics',
    method: 'get'
  })
}

// 获取订单列表
export function getOrderList(params) {
  console.log('API调用参数:', params)
  return request({
    url: '/api/admin/order/list',
    method: 'get',
    params
  })
}

// 获取订单详情
export function getOrderDetail(id) {
  return request({
    url: `/api/admin/order/${id}`,
    method: 'get'
  })
}

// 更新订单状态
export function updateOrderStatus(id, status, remark) {
  return request({
    url: `/api/admin/order/${id}/status`,
    method: 'put',
    params: {
      status,
      remark
    }
  })
}

// 获取订单流程记录
export function getOrderProcessLogs(orderId) {
  return request({
    url: `/api/admin/order/${orderId}/process-logs`,
    method: 'get'
  })
}

// 添加订单流程记录
export function addOrderProcessLog(orderId, processType, content, operatorId) {
  return request({
    url: `/api/admin/order/${orderId}/process-log`,
    method: 'post',
    params: {
      processType,
      content,
      operatorId
    }
  })
}

// 获取订单数据分析
export function getOrderAnalysisData(analysisType, startDate, endDate) {
  return request({
    url: '/api/admin/order/analysis',
    method: 'get',
    params: {
      analysisType,
      startDate,
      endDate
    }
  })
}

// 获取未处理纠纷列表
export function getPendingDisputeList(page, size) {
  return request({
    url: '/api/admin/order/disputes/pending',
    method: 'get',
    params: {
      page,
      size
    }
  })
}

// 获取所有纠纷列表
export function getAllDisputeList(status, page, size) {
  return request({
    url: '/api/admin/order/disputes',
    method: 'get',
    params: {
      status,
      page,
      size
    }
  })
}

// 获取纠纷详情
export function getDisputeDetail(id) {
  return request({
    url: `/api/admin/order/dispute/${id}`,
    method: 'get'
  })
}

// 处理纠纷
export function processDispute(id, status, resolution, operatorId) {
  return request({
    url: `/api/admin/order/dispute/${id}`,
    method: 'put',
    params: {
      status,
      resolution,
      operatorId
    }
  })
}

// 删除订单
export function deleteOrder(id) {
  return request({
    url: `/api/admin/order/${id}`,
    method: 'delete'
  })
} 